//
//  ReverbFactoryItemView.m
//  HLRecord
//
//  Created by XTW on 2023/1/11.
//

#import "ReverbFactoryItemView.h"

@interface ReverbFactoryItemView()
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (nonatomic, assign) BOOL isSelected;

@end

@implementation ReverbFactoryItemView

- (instancetype)initCustomView:(CGRect)frame index:(NSInteger)index {
    self = [[[NSBundle mainBundle] loadNibNamed:@"ReverbFactoryItemView" owner:self options:nil] lastObject];
    if (self) {
        [self setFrame:frame];
        self.nameLabel.text = [self getFactoryName:index];
        self.isSelected = NO;
        self.index = index;
    }
    return self;
}

- (IBAction)clickPress {
    self.isSelected = !self.isSelected;
    [self refresh];
    if (self.isSelected) {
        if (self.ChooseHandle) {
            self.ChooseHandle(self);
        }
    } else {
        if (self.ChooseHandle) {
            self.ChooseHandle(nil);
        }
    }
}

- (void)cancelSelect {
    self.isSelected = NO;
    [self refresh];
}

- (void)refresh {
    if (self.isSelected) {
        self.layer.borderWidth = 1.0f;
        self.layer.borderColor = ThemeColor.CGColor;
    } else {
        self.layer.borderWidth = 0;
    }
}

- (NSString *)getFactoryName:(NSInteger)index {
    switch (index) {
        case 0:
            return @"小房间";
            break;
        case 1:
            return @"中房间";
            break;
        case 2:
            return @"大房间";
            break;
        case 3:
            return @"中等\n大厅";
            break;
        case 4:
            return @"大厅";
            break;
        case 5:
            return @"光滑\n墙面";
            break;
        case 6:
            return @"中等\n会议厅";
            break;
        case 7:
            return @"大型\n会议厅";
            break;
        case 8:
            return @"教堂";
            break;
        case 9:
            return @"大型\n房间2";
            break;
        case 10:
            return @"中等\n大厅2";
            break;
        case 11:
            return @"中等\n大厅3";
            break;
        case 12:
            return @"大厅2";
            break;
        default:
            return @"默认";
            break;
    }
}
@end
